package com.exchange.dto;

import com.exchange.entity.ExchangeCode;
import lombok.Data;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Data
public class ExchangeCodeDto {
    private Long id;
    private String code;
    private Long merchantId;
    private ExchangeCode.ExchangeCodeStatus status;
    private LocalDate expirationDate;
    private LocalDateTime createdAt;
    private LocalDateTime usedAt;
    private String usedBy;
    
    public static ExchangeCodeDto fromEntity(ExchangeCode code) {
        ExchangeCodeDto dto = new ExchangeCodeDto();
        dto.setId(code.getId());
        dto.setCode(code.getCode());
        dto.setMerchantId(code.getMerchantId());
        dto.setStatus(code.getStatus());
        dto.setExpirationDate(code.getExpirationDate());
        dto.setCreatedAt(code.getCreatedAt());
        dto.setUsedAt(code.getUsedAt());
        dto.setUsedBy(code.getUsedBy());
        return dto;
    }
}